<script setup lang="ts">
// 定义defineEmits方法
// eslint-disable-next-line no-undef
let $emit = defineEmits(["xxx","click"]);
console.log($emit);
const handler = () => {
  // 第一个参数事件类型，其后参数传递的数据
  $emit("xxx", "hello");
};
</script>
<template>
  <div class="son">
    <h2>子组件2</h2>
    <button @click="$emit('click', '自定义click')">点击我触发自定义click事件</button>
    <button @click="handler">点击我触发自定义事件回调</button>
  </div>
</template>

<style scoped>
.son {
  width: 400px;
  height: 200px;
  background: salmon;
}
</style>
